<?php
include "../../Koneksi/koneksi.php";

$cekJumlah = mysql_query("select count(kodeIdentitasKelas) 'jumlah' from waliKelas");
$cekKode=mysql_fetch_array($cekJumlah);
$kodeIdentitasKelas = $cekKode['jumlah']+1;

$namaKelas = $_POST['kelas'];
$namaWali = $_POST['pendidik'];


$cek = mysql_fetch_array(mysql_query("SELECT kelas FROM walikelas WHERE kelas='$namaKelas'"));
if (empty($cek['namaKelas'])) {
    mysql_query("insert into walikelas (kodeIdentitasKelas, kelas, pendidik) value "
            . "('$kodeIdentitasKelas' ,'$namaKelas' ,"
            . "'$namaWali')");
    $result = header('location:../Form/FormWaliKelas.php');
} else {
    ?>
    <script>alert("Data Wali Kelas Sudah Ada");
                    document.location.href = "../Form/FormWaliKelas.php"</script>
    <?php
}

echo $result;
?>